﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace Three
{
    internal abstract class BOEScene:ISceneUpdate
    {
        protected string title;
        protected string strOne;

        //选项Index
        protected int choiceIndex = 0;

        public void Update()
        {
            //重设颜色
            Console.ForegroundColor = ConsoleColor.White;

            //标题
            Console.SetCursorPosition(Game.w / 2 - title.Length, 5);
            Console.Write(title);

            //选项
            Console.SetCursorPosition(Game.w / 2 - strOne.Length, 8);
            Console.ForegroundColor = choiceIndex==0? ConsoleColor.Red : ConsoleColor.White;
            Console.Write(strOne);

            Console.SetCursorPosition(Game.w / 2 - 4, 10);
            Console.ForegroundColor = choiceIndex == 1 ? ConsoleColor.Red : ConsoleColor.White;
            Console.Write("结束游戏");

            switch (Console.ReadKey(true).Key)
            {
                case ConsoleKey.W:
                    choiceIndex = Math.Max(0, choiceIndex - 1);
                    break;
                case ConsoleKey.S:
                    choiceIndex = Math.Min(1, choiceIndex + 1);
                    break;
                case ConsoleKey.J:
                    EnterJDoSomethings();
                    break;
            }
        }

        protected abstract void EnterJDoSomethings();

    }
}
